package com.wondersgroup.fjzlpt.console.controller.rest.user;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.boot.web.wapper.QuickPrincipal;
import com.wondersgroup.fjzlpt.console.constant.SystemConstant;
import com.wondersgroup.fjzlpt.console.service.inter.user.UserService;
import com.wondersgroup.fjzlpt.console.utils.ControllerCommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by lion on 2017/5/26.
 */
@RestController
@RequestMapping("/user")
public class UserRestController {

    @Autowired
    private UserService userService;

    @RequestMapping("/queryPageUser")
    public JSONObject queryPageUser(HttpServletRequest request)
    {
        Map map = ControllerCommonUtils.getUserQqueryPower(request);
        return userService.queryPage(map);
    }

    @RequestMapping("/queryRoleMenu")
    public JSONArray queryRoleMenu(HttpServletRequest request){
        String roleId = request.getParameter("ROLEID");
        return userService.queryRoleMenu(roleId);
    }

    @RequestMapping("/save")
    public JSONObject save(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return userService.save(map);
    }

    @RequestMapping("/delete")
    public JSONObject delete(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return userService.delete(map);
    }

    @RequestMapping("/updateUserState")
    public JSONObject updateUserState(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return userService.updateUserState(map);
    }
}
